﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SKYPE4COMLib;

namespace Gype.GUI
{
    internal static class UserManager
    {
        private static Dictionary<string, User> mUserCollection = new Dictionary<string, User>();

        public static void AddUser(User user)
        {
            string handle = user.Handle;
            handle = handle.ToLower();
            if (mUserCollection.ContainsKey(handle))
                return;

            mUserCollection.Add(handle, user);
        }

        public static User GetUser(string handle)
        {
            if (!mUserCollection.ContainsKey(handle.ToLower()))
                return null;

            return mUserCollection[handle.ToLower()];
        }

        public static string GetUserName(string handle)
        {
            var user = GetUser(handle);
            if (user == null)
                return handle;

            if (!string.IsNullOrEmpty(user.DisplayName))
                return user.DisplayName;

            if (!string.IsNullOrEmpty(user.FullName))
                return user.FullName;

            return handle;
        }
    }
}
